package com.guigu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guigu.mapper.SysUsersMapper;
import com.guigu.pojo.SysUsers;
import com.guigu.service.SysUsersService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 后台员工表 服务实现类
 * </p>
 *
 * @author Mr.Zhang
 * @since 2025-03-12
 */
@Service
@Transactional
public class SysUsersServiceImpl extends ServiceImpl<SysUsersMapper, SysUsers> implements SysUsersService {

    @Override
    @Transactional
    public SysUsers login(String loginName, String password) {
        SysUsers user = baseMapper.selectOne(new QueryWrapper<SysUsers>()
                .eq("login_name", loginName)
                .eq("password", password));
        return user;
    }

    @Override
    public List<SysUsers> getUserList(SysUsers queryParams) {
        return baseMapper.selectUserList(queryParams);
    }


    @Override
    @Transactional
    public int addUser(SysUsers sysUsers) {
        return baseMapper.insertUser(sysUsers);
    }

    @Override
    @Transactional
    public int updateUser(SysUsers sysUsers) {
        return baseMapper.updateUser(sysUsers);
    }

    @Override
    @Transactional
    public int deleteUserById(Integer userId) {
        return baseMapper.deleteUserById(userId);
    }

    @Override
    @Transactional
    public int deleteUsersByIds(List<Integer> userIds) {
        return baseMapper.deleteUsersByIds(userIds);
    }
}
